package com.keyinong.parkin.home.adapter;

import java.util.ArrayList;

import com.example.parkin.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class AdListAdapter extends BaseAdapter {
	private ArrayList<Integer> list;
	private Context context;

	public AdListAdapter(ArrayList<Integer> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {

		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHandle handle;
		if (view == null) {
			handle = new ViewHandle();
			view = LayoutInflater.from(context).inflate(R.layout.item_list_img,
					null);
			handle.img_adImg=(ImageView) view.findViewById(R.id.img_adImg);
			view.setTag(handle);
		}else{
			handle=(ViewHandle) view.getTag();
		}
		handle.img_adImg.setImageResource(list.get(position));
		return view;
	}

	private class ViewHandle {
		ImageView img_adImg;
	}

}
